import 'dart:typed_data';

import 'package:jieli_ble_ota_plugin/jieli_ble_ota_plugin.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'jieli_ble_ota_plugin_method_channel.dart';

abstract class JieliBleOtaPluginPlatform extends PlatformInterface {
  /// Constructs a JieliBleOtaPluginPlatform.
  JieliBleOtaPluginPlatform() : super(token: _token);

  static final Object _token = Object();

  static JieliBleOtaPluginPlatform _instance = MethodChannelJieliBleOtaPlugin();

  /// The default instance of [JieliBleOtaPluginPlatform] to use.
  ///
  /// Defaults to [MethodChannelJieliBleOtaPlugin].
  static JieliBleOtaPluginPlatform get instance => _instance;

  /// Platform-specific implementations should set this with their own
  /// platform-specific class that extends [JieliBleOtaPluginPlatform] when
  /// they register themselves.
  static set instance(JieliBleOtaPluginPlatform instance) {
    PlatformInterface.verifyToken(instance, _token);
    _instance = instance;
  }

  Future writeData(Uint8List bytes);

  void onOtaUpdateProgressChanged(int type, double progress);

  void onOtaUpdateSuccess();

  void onOtaUpdateFailed(String code);

  void onDeviceFirmwareStatusRequested(bool success, bool isFirmwareBroken);

  void notifyDataReceived(Uint8List bytes);

  void notifyLinkConnected(String identifier, String name);

  void notifyLinkDisconnected(String identifier, String name);

  void startOta(String file);

  void requestDeviceFirmwareState();

  void setDataWriteHandler(DataWriteHandler dataWriteHandler);

  void setOtaCallback(OtaCallback otaCallback);

  void setLinkLayerHandler(LinkLayerHandler handler);
}
